home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / gdevpsds.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  5.5 KB  |  153 lines

  1. /* Copyright (C) 1997, 2000 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: gdevpsds.h,v 1.4 2000/09/19 19:00:21 lpd Exp $ */
  20. /* Image processing stream interface for PostScript and PDF writers */
  21.  
  22. #ifndef gdevpsds_INCLUDED
  23. #  define gdevpsds_INCLUDED
  24.  
  25. #include "strimpl.h"
  26.  
  27. /* ---------------- Depth conversion ---------------- */
  28.  
  29. /* Convert between 1/2/4/12 bits and 8 bits. */
  30. typedef struct stream_1248_state_s {
  31.     stream_state_common;
  32.     /* The following are set at initialization time. */
  33.     uint samples_per_row;    /* >0 */
  34.     int bits_per_sample;    /* 1, 2, 4, 12 */
  35.     /* The following are updated dynamically. */
  36.     uint left;            /* # of samples left in current row */
  37. } stream_1248_state;
  38.  
  39. /* Convert N (1, 2, 4, 12) bits to 8. */
  40. extern const stream_template s_1_8_template;
  41. extern const stream_template s_2_8_template;
  42. extern const stream_template s_4_8_template;
  43. extern const stream_template s_12_8_template;
  44.  
  45. /* Reduce 8 bits to N (1, 2, 4). */
  46. /* We do not currently support converting 8 bits to 12. */
  47. extern const stream_template s_8_1_template;
  48. extern const stream_template s_8_2_template;
  49. extern const stream_template s_8_4_template;
  50.  
  51. /* Initialize an expansion or reduction stream. */
  52. int s_1248_init(P3(stream_1248_state *ss, int Columns, int samples_per_pixel));
  53.  
  54. /* ---------------- Color space conversion ---------------- */
  55.  
  56. /* Convert (8-bit) CMYK to RGB. */
  57. typedef struct stream_C2R_state_s {
  58.     stream_state_common;
  59.     /* The following are set at initialization time. */
  60.     const gs_imager_state *pis;    /* for UCR & BG */
  61. } stream_C2R_state;
  62.  
  63. #define private_st_C2R_state()    /* in gdevpsds.c */\
  64.   gs_private_st_ptrs1(st_C2R_state, stream_C2R_state, "stream_C2R_state",\
  65.     c2r_enum_ptrs, c2r_reloc_ptrs, pis)
  66. extern const stream_template s_C2R_template;
  67.  
  68. /* Initialize a CMYK => RGB conversion stream. */
  69. int s_C2R_init(P2(stream_C2R_state *ss, const gs_imager_state *pis));
  70.  
  71. /* Convert an image to indexed form (IndexedEncode filter). */
  72. typedef struct stream_IE_state_s {
  73.     stream_state_common;
  74.     /* The client sets the following before initializing the stream. */
  75.     int BitsPerComponent;    /* 1, 2, 4, 8 */
  76.     int NumComponents;
  77.     int Width;            /* pixels per scan line, > 0 */
  78.     int BitsPerIndex;        /* 1, 2, 4, 8 */
  79.     /*
  80.      * Note: this is not quite the same as the Decode array for images:
  81.      * [0..1] designates the range of the corresponding component of the
  82.      * color space, not the literal values 0..1.  This is the same for
  83.      * all color spaces except Lab, where the default values here are
  84.      * [0 1 0 1 0 1] rather than [0 100 amin amax bmin bmax].
  85.      */
  86.     const float *Decode;
  87.     /*
  88.      * The client must provide a Table whose size is at least
  89.      * ((1 << BitsPerIndex) + 1) * NumComponents.  After the stream is
  90.      * closed, the first (N + 1) * NumComponents bytes of the Table
  91.      * will hold the palette, where N is the contents of the last byte of
  92.      * the Table.
  93.      */
  94.     gs_bytestring Table;
  95.     /* The following change dynamically. */
  96.     int hash_table[400];    /* holds byte offsets in Table */
  97.     int next_index;        /* next Table offset to assign */
  98.     uint byte_in;
  99.     int in_bits_left;
  100.     int next_component;
  101.     uint byte_out;
  102.     int x;
  103. } stream_IE_state;
  104.  
  105. #define private_st_IE_state()    /* in gdevpsds.c */\
  106.   gs_public_st_composite(st_IE_state, stream_IE_state, "stream_IE_state",\
  107.     ie_state_enum_ptrs, ie_state_reloc_ptrs)
  108.  
  109. extern const stream_template s_IE_template;
  110.  
  111. /* ---------------- Downsampling ---------------- */
  112.  
  113. /* Downsample, possibly with anti-aliasing. */
  114. #define stream_Downsample_state_common\
  115.     stream_state_common;\
  116.         /* The client sets the following before initialization. */\
  117.     int Colors;\
  118.     int WidthIn, HeightIn;\
  119.     int XFactor, YFactor;\
  120.     bool AntiAlias;\
  121.     bool padX, padY;    /* keep excess samples */\
  122.         /* The following are updated dynamically. */\
  123.     int x, y        /* position within input image */
  124. #define s_Downsample_set_defaults_inline(ss)\
  125.   ((ss)->AntiAlias = (ss)->padX = (ss)->padY = false)
  126. typedef struct stream_Downsample_state_s {
  127.     stream_Downsample_state_common;
  128. } stream_Downsample_state;
  129.  
  130. /* Return the number of samples after downsampling. */
  131. int s_Downsample_size_out(P3(int size_in, int factor, bool pad));
  132.  
  133. /* Subsample */
  134. typedef struct stream_Subsample_state_s {
  135.     stream_Downsample_state_common;
  136. } stream_Subsample_state;
  137. extern const stream_template s_Subsample_template;
  138.  
  139. /* Average */
  140. typedef struct stream_Average_state_s {
  141.     stream_Downsample_state_common;
  142.     uint sum_size;
  143.     uint copy_size;
  144.     uint *sums;            /* accumulated sums for average */
  145. } stream_Average_state;
  146.  
  147. #define private_st_Average_state()    /* in gdevpsds.c */\
  148.   gs_private_st_ptrs1(st_Average_state, stream_Average_state,\
  149.     "stream_Average_state", avg_enum_ptrs, avg_reloc_ptrs, sums)
  150. extern const stream_template s_Average_template;
  151.  
  152. #endif /* gdevpsds_INCLUDED */
  153.